{template "header.html"}
<style>
    label {
        margin-bottom: 15px;
    }
</style>
<div class="page-wrapper-row full-height">
    <div class="page-wrapper-middle">
        <div class="page-head">
            <div class="container">
                <div class="page-title" style="color:red">
                    这里是demo模块的搜索页，以下有组合搜索的写法
                </div>
            </div>
        </div>
        <div class="page-content">

            <div class="container">

                <ul class="page-breadcrumb breadcrumb">
                    <li>
                        <a href="{SITE_URL}">网站首页</a>
                        <i class="fa fa-circle"></i>
                    </li>
                    <li>
                        <a href="{MODULE_URL}">{MODULE_NAME}</a>
                        <i class="fa fa-circle"></i>
                    </li>
                    {dr_catpos($catid, '', true, '<li><a href="[url]">[name]</a><i class="fa fa-circle"></i></li>')}
                    <li>
                        <span>搜索</span>
                    </li>
                </ul>

                <div class="search-page search-content-1">

                    <div class="portlet light">
                        <div class="portlet-title">
                            <div class="caption">
                                <span class="caption-subject font-green-sharp"> 条件筛选 </span>
                            </div>
                        </div>
                        <div class="portlet-body form fc-search-param">
                            <div class="form-body">



                                <div class="form-group row">
                                    <label class="col-md-2 control-label">一级栏目分类</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$cat}label-success{else}label-default{/if}" href="{Router::search_url($params, 'catid', NULL)}">不限</a></label>
                                        {category pid=0}
                                        <label><a class="label {if dr_in_array($cat.id, $t.catids)}label-success{else}label-default{/if}" href="{Router::search_url($params, 'catid', $t.id)}">{$t.name}</a></label>
                                        {/category}
                                    </div>
                                </div>
                                {if $cat}

                                <div class="form-group row">
                                    <label class="col-md-2 control-label">二级栏目分类</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$cat || $cat.child}label-success{else}label-default{/if}" href="{Router::search_url($params, 'catid', $cat.id)}">不限</a></label>
                                        <!--调用栏目分类，这种用法只能用于模块列表与搜索页面-->
                                        {loop $related $t}
                                        <label><a class="label {if $t.id==$cat.id}label-success{else}label-default{/if}" href="{Router::search_url($params, 'catid', $t.id)}">{$t.name}</a></label>
                                        {/loop}
                                    </div>
                                </div>
                                {/if}

                                <!--category_search_field是调用当前栏目下的附加字段是否具有搜索字段功能，这种用法只能用于模块列表与搜索页面-->
                                {category_search_field module=MOD_DIR catid=$catid}
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">{$t.name}</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params[$t.field]}label-success{else}label-default{/if}" href="{Router::search_url($params, $t.field, NULL)}">不限</a></label>
                                        {loop $t.data $v}
                                        <label><a class="label {if $v.value==$params[$t.field]}label-success{else}label-default{/if}" href="{Router::search_url($params, $t.field, $v.value)}">{$v.name}</a></label>
                                        {/loop}
                                    </div>
                                </div>
                                {/category_search_field}

                                <!--按联动菜单搜索-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">联动菜单</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.csxz || dr_linkage('address', $params.csxz, 0, 'child')}label-success{else}label-default{/if}" href="{Router::search_url($params, 'csxz', NULL)}">不限</a></label>
                                        <!--调用联动菜单address，pid为动态获取的地区id-->
                                        {list action=linkage code=address pid=$params.csxz}
                                        <label><a class="label {if $t.id==$params.csxz}label-success{else}label-default{/if}" href="{Router::search_url($params, 'csxz', $t.id)}">{$t.name}</a></label>
                                        {/list}
                                    </div>
                                </div>

                                <!--单选按钮字段搜索-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">单选字段</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.danxuananniu}label-success{else}label-default{/if}" href="{Router::search_url($params, 'danxuananniu', NULL)}">不限</a></label>
                                        <!--调用单选字段数据方法-->
                                        {php $field = dr_field_options($ci->module['field']['danxuananniu']['id']);}
                                        {loop $field $value $name}
                                        <label><a class="label {if $value==$params.danxuananniu}label-success{else}label-default{/if}" href="{Router::search_url($params, 'danxuananniu', $value)}">{$name}</a></label>
                                        {/loop}
                                    </div>
                                </div>

                                <!--单选按钮字段搜索-多条件-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">单选字段-多条件</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.danxuananniu}label-success{else}label-default{/if}" href="{Router::search_url($params, 'danxuananniu', NULL)}">不限</a></label>
                                        <!--调用单选字段数据方法-->
                                        {php $field = dr_field_options($ci->module['field']['danxuananniu']['id']);}
                                        {loop $field $value $name}
                                        <label><a class="label {if dr_is_double_search($params.danxuananniu, $value)}label-success{else}label-default{/if}" href="{Router::search_url($params, 'danxuananniu', dr_get_double_search($params.danxuananniu, $value))}">{$name}</a></label>
                                        {/loop}
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">复选字段-多条件</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.fuxuankuang}label-success{else}label-default{/if}" href="{Router::search_url($params, 'fuxuankuang', NULL)}">不限</a></label>
                                        <!--调用单选字段数据方法-->
                                        {php $field = dr_field_options($ci->module['field']['fuxuankuang']['id']);}
                                        {loop $field $value $name}
                                        <label><a class="label {if dr_is_double_search($params.fuxuankuang, $value)}label-success{else}label-default{/if}" href="{Router::search_url($params, 'fuxuankuang', dr_get_double_search($params.fuxuankuang, $value))}">{$name}</a></label>
                                        {/loop}
                                    </div>
                                </div>


                                <!--复选字段搜索-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">复选字段</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.fuxuankuang}label-success{else}label-default{/if}" href="{Router::search_url($params, 'fuxuankuang', NULL)}">不限</a></label>
                                        <!--调用字段数据方法-->
                                        {php $field = dr_field_options($ci->module['field']['fuxuankuang']['id']);}
                                        {loop $field $value $name}
                                        <label><a class="label {if $value==$params.fuxuankuang}label-success{else}label-default{/if}" href="{Router::search_url($params, 'fuxuankuang', $value)}">{$name}</a></label>
                                        {/loop}
                                    </div>
                                </div>
                                <!--下拉框字段搜索-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">下拉选择字段</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.xialaxuanze}label-success{else}label-default{/if}" href="{Router::search_url($params, 'xialaxuanze', NULL)}">不限</a></label>
                                        <!--调用单选字段数据方法-->
                                        {php $field = dr_field_options($ci->module['field']['xialaxuanze']['id']);}
                                        {loop $field $value $name}
                                        <label><a class="label {if $value==$params.xialaxuanze}label-success{else}label-default{/if}" href="{Router::search_url($params, 'xialaxuanze', $value)}">{$name}</a></label>
                                        {/loop}
                                    </div>
                                </div>

                                <!--下拉框字段搜索2222-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label">用户表下拉选择字段</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.quyu}label-success{else}label-default{/if}" href="{Router::search_url($params, 'quyu', NULL)}">不限</a></label>
                                        <!--调用单选字段数据方法-->
                                        {php $field = dr_field_options($ci->member_cache['field']['quyu']['id']);}
                                        {loop $field $value $name}
                                        <label><a class="label {if $value==$params.quyu}label-success{else}label-default{/if}" href="{Router::search_url($params, 'quyu', $value)}">{$name}</a></label>
                                        {/loop}
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-md-2 control-label">单一购买价格</label>
                                    <div class="col-md-9">
                                        <!--自定义一个价格返回数组，这个都懂得，php最基础的数组用法-->
                                        {php $price=array('0,500'=>'500以内','500,1000'=>'500到1000','1000,2000'=>'1000到2000','2000,3000'=>'2000到3000','3000,0'=>'3000以上');}
                                        <label><a class="label {if !$params.dydgm}label-success{else}label-default{/if}" href="{Router::search_url($params, 'dydgm', NULL)}">不限</a></label>
                                        {loop $price $i $t}
                                        <label><a class="label {if $i==$params.dydgm}label-success{else}label-default{/if}" href="{Router::search_url($params, 'dydgm', $i)}">{$t}</a></label>
                                        {/loop}
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-md-2 control-label">组合购买价格自定义</label>
                                    <div class="col-md-9">
                                        {php $zhxgm = explode(',', $params.zhxgm);}
                                        <label><input type="text" class="form-control" value="{$zhxgm[0]}" id="zhxgm_min"></label>
                                        <label>到</label>
                                        <label><input type="text" class="form-control" value="{$zhxgm[1]}" id="zhxgm_max"></label>
                                        <label>这是自定义价格范围搜索的写法</label>
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-md-2 control-label">时间段的搜索写法</label>
                                    <div class="col-md-9">

                                        <link href="{THEME_PATH}assets/global/plugins/bootstrap-daterangepicker/daterangepicker.min.css" rel="stylesheet" type="text/css" />
                                        <link href="{THEME_PATH}assets/global/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css" rel="stylesheet" type="text/css" />
                                        <link href="{THEME_PATH}assets/global/plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css" rel="stylesheet" type="text/css" />
                                        <link href="{THEME_PATH}assets/global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" />
                                        <script src="{THEME_PATH}assets/global/plugins/bootstrap-datepicker/js/bootstrap-datepicker.finecms.js" type="text/javascript"></script>

                                        <script type="text/javascript">
                                            jQuery(document).ready(function() {
                                                if (jQuery().datepicker) {
                                                    $('.date-picker').datepicker({
                                                        orientation: "left",
                                                        autoclose: true
                                                    });
                                                }
                                            });
                                        </script>
                                        {php $updatetime = explode(',', $params.updatetime);}
                                        <label><div class="input-group  date-picker input-daterange" data-date="" data-date-format="yyyy/mm/dd">
                                            <input type="text" class="form-control" value="{$updatetime[0]}" id="updatetime_min">
                                            <span class="input-group-addon"> {dr_lang('到')} </span>
                                            <input type="text" class="form-control" value="{$updatetime[1]}" id="updatetime_max">
                                        </div></label>


                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="col-md-2 control-label">用户组</label>
                                    <div class="col-md-9">
                                        <label><a class="label {if !$params.groupid}label-success{else}label-default{/if}" href="{Router::search_url($params, 'groupid', NULL)}">不限</a></label>
                                        <!--调用栏目分类，这种用法只能用于模块列表与搜索页面-->
                                        {loop $ci->member_cache['group'] $t}
                                        <label><a class="label {if $t.id==$params.groupid}label-success{else}label-default{/if}" href="{Router::search_url($params, 'groupid', $t.id)}">{$t.name}</a></label>
                                        {/loop}
                                    </div>
                                </div>

                                <!--按关键字搜索-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label" style="padding-top:5px">内容搜索</label>
                                    <div class="col-md-6">
                                        <div class="input-group">
                                            <input type="text" class="form-control" onkeypress="if(event.keyCode==13) {dr_module_search();return false;}" name='keyword' value='{$keyword}' id='search_keyword'>
                                            <span class="input-group-btn">
                                                <button class="btn blue" onclick="dr_module_search()" type="button"> <i class="fa fa-search"></i> 搜索</button>
                                            </span>
                                        </div>
                                    </div>
                                </div>
                                <script>
                                    // 这段js是用来执行搜索的
                                    function dr_module_search(name) {
                                        var url="{Router::search_url($params, ['keyword', 'zhxgm', 'updatetime'], ['mykeyword', 'myzhxgm', 'myupdatetime'])}";
                                        // 这是按关键词的写法参数替换
                                        var keyword = $("#search_keyword").val();
                                        if (keyword) {
                                            url = url.replace('mykeyword', keyword);
                                        } else {
                                            url = url.replace('mykeyword', '');
                                        }

                                        // 这是按价格范围的写法参数替换
                                        var zhxgm_min = $("#zhxgm_min").val();
                                        var zhxgm_max = $("#zhxgm_max").val();
                                        zhxgm_max = zhxgm_max ? zhxgm_max : 0;
                                        zhxgm_min = zhxgm_min ? zhxgm_min : 0;
                                        if (zhxgm_max || zhxgm_min) {
                                            url = url.replace('myzhxgm', zhxgm_min+','+zhxgm_max);
                                        } else {
                                            url = url.replace('myzhxgm', '');
                                        }

                                        // 这是时间格范围的写法参数替换
                                        var updatetime_min = $("#updatetime_min").val();
                                        var updatetime_max = $("#updatetime_max").val();
                                        updatetime_max = updatetime_max ? updatetime_max : 0;
                                        updatetime_min = updatetime_min ? updatetime_min : 0;
                                        if (updatetime_max || updatetime_min) {
                                            url = url.replace('myupdatetime', updatetime_min+','+updatetime_max);
                                        } else {
                                            url = url.replace('myupdatetime', '');
                                        }

                                        // 跳转搜索页面
                                        location.href=url;
                                        return false;
                                    }
                                </script>

                                <!--已经选择-->
                                <div class="form-group row">
                                    <label class="col-md-2 control-label" style="padding-top:5px">已经选择</label>
                                    <div class="col-md-9" style="padding-top: 7px;">
                                        <!--手动获取参数写法-->
                                        {if $params['order']}
                                        <label><a href="{Router::search_url($params, 'order', NULL)}" class="btn btn-xs red">排序：{$params['order']} <i class="fa fa-times"></i> </a></label>
                                        {/if}
                                        <!--自动获取小部分的搜索数组写法-->
                                        {loop $param_value $p $v}
                                        <label><a href="{Router::search_url($params, $p, NULL)}" class="btn btn-xs red">{$v.name}：{$v.value} <i class="fa fa-times"></i> </a></label>
                                        {/loop}
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                    <div class="portlet light">
                        <div class="portlet-title">
                            <div class="caption">
                                <span class="caption-subject font-green-sharp"> 筛选结果 </span>
                            </div>
                            <div class="actions">
                                <div class="btn-group">
                                    <a href="{Router::search_url($params, 'order', null)}" class="btn btn-default {if !$params.order || $param.order=='updatetime'}active{/if}"> <i class="fa fa-clock-o"></i> 时间排序 </a>
                                    <a href="{Router::search_url($params, 'order', 'hits')}" class="btn btn-default {if $params.order=='hits'}active{/if}"> <i class="fa fa-eye"></i> 点击排序 </a>
                                    <a href="{Router::search_url($params, 'order', 'comments')}" class="btn btn-default {if $params.order=='comments'}active{/if}"> <i class="fa fa-comments-o"></i> 评论排序 </a>
                                    <a href="{Router::search_url($params, 'order', 'avgsort')}" class="btn btn-default {if $params.order=='avgsort'}active{/if}"> <i class="fa fa-diamond"></i> 评分排序 </a>
                                    <a href="{Router::search_url($params, 'order', 'support')}" class="btn btn-default {if $params.order=='support'}active{/if}"> <i class="fa fa-digg"></i> 支持量排序 </a>
                                    <a href="{Router::search_url($params, 'order', 'donation')}" class="btn btn-default {if $params.order=='donation'}active{/if}"> <i class="fa fa-rmb"></i> 赞助排序 </a>
                                </div>
                            </div>
                        </div>
                        <div class="portlet-body search-container ">
                            <ul>
                                <!--调用MOD_DIR模块的数据 id和total和order参数(本页面固有参数) page=1标示开启分页 urlrule分页地址规则 pagesize每页数量-->
                                {search module=MOD_DIR id=$searchid total=$sototal order=$params.order catid=$catid page=1 pagesize=5 urlrule=$urlrule}
                                <li class="search-item clearfix">
                                    <a title="{$t.title}" href="{$t.url}">
                                        <img src="{dr_thumb($t.thumb, 100, 90)}" width="100" height="90" style="margin-top: 15px;">
                                    </a>
                                    <div class="search-content text-left">
                                        <h4 class="search-title">
                                            <a title="{$t.title}" href="{$t.url}">{$t.title}</a>
                                        </h4>
                                        <p class="search-desc">{$t.description}</p>
                                        <div class="search-post-foot">
                                            <ul class="search-post-tags">
                                                {php $kw=@explode(',', $t.keywords);}
                                                {loop $kw $a}
                                                {if $a}
                                                <li class="uppercase">
                                                    <a href="{Router::tag_url($a)}" target="_blank">{$a}</a>
                                                </li>
                                                {/if}
                                                {/loop}
                                            </ul>
                                            <div class="search-post-meta">
                                                <i class="fa fa-calendar font-blue"></i>
                                                <a href="javascript:;">{$t.updatetime}</a>
                                            </div>
                                            <div class="search-post-meta">
                                                <i class="fa fa-eye font-blue"></i>
                                                <a href="javascript:;">{$t.hits}</a>
                                            </div>
                                            <div class="search-post-meta">
                                                <i class="fa fa-comments font-blue"></i>
                                                <a href="javascript:;">{$t.comments}</a>
                                            </div>
                                        </div>
                                    </div>
                                </li>
                                {/search}
                            </ul>

                            {if !$count}
                            <div class="row fc-search-null">
                                <div class="col-md-12 text-center">
                                    <i class="fa fa-close fc-search-null-icon"></i>
                                    <label class="fc-search-null-txt">没有找到相关内容...</label>
                                </div>

                            </div>
                            {/if}
                            <div class="search-pagination">
                                <ul class="pagination">
                                    {$pages}
                                </ul>
                            </div>
                            <div class=" text-left">
                                {$debug}
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </div>
    </div>
</div>

{template "footer.html"}